package mmc.server.shell.ops.baseops;

import mmc.server.shell.*;
import mmc.server.shell.ops.*;

public class PreDecrement extends Operation {

    public PreDecrement(String text) throws ShellException {
        super(text, "--", false, true);
        
        if(!(rValue instanceof Assignable)){
        	throw new OperationNotAcceptedException(false, " rvalue is not a variable! ("+lValue.getClass().getName()+")");
        }
    }

    @Override
    public double execute() {
    	double value = rValue.execute()-1;
    	((Assignable)rValue).set(value);
    	
    	return value;
    }
    
    public static PriorityType getPriorityType() {
        return PriorityType.UNARY_OP;
    }
    
    public static String getDescription(){
    	return formatHelpString("--","decrement (pre)");
    }
}
